package cn.itcast.ssm.service.impl;

import cn.itcast.ssm.mapper.CropMapper;
import cn.itcast.ssm.po.Crop;
import cn.itcast.ssm.service.CropService;
import cn.itcast.ssm.util.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CropServiceImpl implements CropService {
    @Autowired
    CropMapper cropMapper;

    @Override
    public List<Crop> selectAllCropName() {
        List list=cropMapper.selectByExample(null);
        List namelist=new ArrayList();
        for(Object crop:list){
            Crop crop1=(Crop)crop;
            namelist.add(crop1.getName());
        }
        return  namelist;
    }

    @Override
    public Crop selectCropByName(String Name) {
        List list=cropMapper.selectByExample(null);
        for(Object crop:list){
            Crop crop1=(Crop)crop;
            if(Name.equals(crop1.getName())){
                return crop1;
            }
        }
        return null;
    }
}
